<?php
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//  Token身份生成与验证               Link: http://www.hlzblog.top/
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

// 引入 云天河写的 Redis类

class Token
{

    /**
     * 随机生成固定长度的随机数
     * @param String  len  截取长度，默认八位
     * @param Int     type 返回类型 [1=>字母+数字,2=>纯数字,3=>纯字母]
     * @return String
     */
    public static function rand_str($len = 8, $type = 1)
    {
        switch ($type) {
            case 1:
                $str = "0123456789qwertyuiopasdfghjklzxcvbnm";
                break;
            case 2:
                $str = "0123456789";
                break;
            default:
                $str = "qwertyuiopasdfghjklzxcvbnm";
        }
        return substr(str_shuffle($str), 0, $len);
    }

}
